<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
 
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include_once($phpbb_root_path . 'common.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include_once($phpbb_root_path . 'sv_common.' . $phpEx);
include_once($phpbb_root_path . 'ofc/php-ofc-library/open-flash-chart.' . $phpEx);

$in_fb_iframe = true;

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('stockvirtual');

$money = $user->data['user_money'];
$user_id 	= $user->data['user_id'];

if ($user_id == ANONYMOUS)
{
	sv_login_box();
}

display_forums('', $config['load_moderators']);

// draw user value
$performance = false;
draw_user_value($user_id);

// As we can only show 1 page in FB iframe, provide a url for the user to get detail.
//$detail_url	= append_sid("{$phpbb_root_path}performance.$phpEx", '');

// list all delegation. 
$list = list_delegation($user_id, true);


// list ROI for 1, 3, 6, 12 month period
list_user_roi($user_id);

// show belief
$show_belief = false;
$sql 	= 'SELECT * FROM sv_personal_setting WHERE user_id=' . $user_id;
$result = $db->sql_query($sql); 
if ($row = $db->sql_fetchrow($result))
{
	$belief = utf8_normalize_nfc($row['belief']);
	if($belief != '')
		$show_belief = true;
}

// include nav links.
include_nav_links();

// Assign index specific vars
$template->assign_vars(array(

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_NEW_POSTS'),
	'FORUM_NEW_IMG'			=> $user->img('forum_unread', 'NEW_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'),
	'FORUM_NEW_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'),
	'JASON_STRING'			=> $jason_string,
	
	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'S_DISPLAY_BIRTHDAY_LIST'	=> ($config['load_birthdays']) ? true : false,
	'U_MONEY'					=> number_format($money),
	'U_USERNAME'				=> $user->data['username'],
	'S_PERFORMANCE'				=> $performance,
	'S_LIST'					=> $list,

	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '',
		
	'IN_FB_IFRAME'		=> $in_fb_iframe,
	
	'DETAIL_URL'		=> $detail_url,
	
	'S_SHOW_BELIEF'		=> $show_belief,
	'S_BELIEF'			=> $belief,
	
	'S_USER_ID'			=> $user_id,
	'S_USERNAME'		=> get_username($user_id),
	
	'S_FB_APP_ID'		=> get_fb_app_id(),
	)
);

// Output page
page_header($user->lang['SV_PERFORMANCE']);

$template->set_filenames(array(
	'body' => 'performance.html')
);

page_footer();

?>